<template>

    <div class="div1">
        {{ msg }}
        {{ rever }}
        {{testprops}}
        <button @click="sendData">向父组件发送数据</button>
        <ul>
            <li v-for="(item, index) in configdata" v-bind:key="item.id">{{index+1}}{{item.title}}{{item.rate}}</li>
        </ul>
        {{ $route.query.username }}{{ $route.query.age }}
    </div>

</template>
<script>
import { request } from '@/networks'
export default {
    name:"first",
    data:function(){
        return {
            msg:"hello",
            configdata:"!!!"
        }
    },
    props:["testprops"],
    computed:{
         rever(){
            return this.msg.split('').reverse().join('');
        }
    },
    methods:{
        sendData(){
            this.$emit("getSon",this.testprops);
            // 发送请求
            request({
            method: 'get',
            url: '/api/j/search_subjects?type=movie&tag=%E8%B1%86%E7%93%A3%E9%AB%98%E5%88%86&sort=recommend&page_limit=20&page_start=0'
            }).then(res=>{
                console.log(res);
                this.configdata=res.data.subjects;
            });
        }
    },
    beforeUpdate:function (){
        alert("数据更新之前"+this.configdata)
    },
    updated:function (){
        alert("数据更新之后"+this.configdata)
    }
}
</script>
<style scoped>
li{
    list-style: none;
    display: inline-block;
}
</style>